<?php 


require "../common/Curl.php";

/**
 *	https://open.esign.cn/doc/detail?id=opendoc%2Fidentity_service%2Feaug1b&namespace=opendoc%2Fidentity_service
 * 	e签宝 认证服务API
 * 	企业认证  认证服务网页版----接口顺序排列封装
 *  使用请求签名鉴权方式
 *  下一个------------------ 企业认证纯API版 authorganapi.php
 */


//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

/**
 * [authOrganName 获取组织机构实名认证地址]
 * @param  [type] $aaaa      [各类参数]
 * @param  [type] $accountId [组织账号id]
 * @return [type]            [description]
 */
function authOrganName($aaaa,$accountId,$appId,$secret,$url){
	$urlss = $url."/v2/identity/auth/web/".$accountId."/orgIdentityUrl";
	$head_url = "/v2/identity/auth/web/".$accountId."/orgIdentityUrl";
    $data = json_decode($aaaa,true);
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
}
// $accountId = "6f69dc0a5c8d415aa6a0c7e239a32241";
// $aaaa = '{
//    	"authType":"ORG_BANK_TRANSFER",
//     "availableAuthTypes":["ORG_BANK_TRANSFER","ORG_ZM_AUTHORIZE"],
//   	"agentAuthAdvancedEnabled":["PSN_TELECOM_AUTHCODE","PSN_BANK4_AUTHCODE"],
//     "agentAccountId":"f120cf3f2a124fc88f8438d6c919b8b6",
//     "contextInfo":{
//     	"contextId":"20190822135330888",
//     	"notifyUrl":"http://baidu.com",
//     	"origin":"BROWSER",
//     	"redirectUrl":"http://baidu.com",
//     	"showResultPage":"true"
//     },
//     "orgEntity":{
//     	"certNo":"546512395648525649",
//     	"organizationType":1,
//     	"name":"赣州刘颂晶网络",
//       "legalRepCertNo":"360731199907050379",
//     	"legalRepName":"liusongjing"
//     },
 
//     "repeatIdentity":"true"
// }';
// $a = authOrganName($aaaa,$accountId,$appId,$secret,$url);
// var_dump($a);die;
// {"code":0,"message":"成功","data":{"url":"https://smlfront.esign.cn:8890/identity/login?appId=7438873193¶m=5y%2B7JHvXaO2IvgucxOVa3uiJgLTKOYYXW4v%2BAiZoEcIK31Q5OeczO4Pptcvg%2FAtXXLprORNI%2BnbQHy6%2FB6GrB6fJVA90Ggu6JT7ZxSN9RHd%2FRaeNaCfq2UjMoVAgdBgE5iwhrHOl51FBx1p0zkNbUvCMFasvoiyBoKjbj1Pn8sNb1sP8uzWBnDwu8quYJDs6iNZzoLdkvZ2%2FySD9QSd30WiFIx49Net6nHfjIVnlXq6LN%2FcgZL0dF4TwR9ToQKNhlMxTME1RssbSgJkwxeTpN0xY%2BffvcQAmRhkBdW2PSMC0XKpgTWjsi1QZt9cnzQelOK0OLwHGzIpvjI6xJKNcA4MjVDVV%2BEIXQWfBWjHb13I%3D&lang=zh-CN","shortLink":"https://smlt.esign.cn/HkYL1Ygk4pwZ","flowId":"1941864529655236119"}}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


/**
 * [authOrganBody 获取组织机构核身认证地址]
 * @param  [type] $aaaa   [各类参数]
 * @return [type]         [description]
 */
function authOrganBody($aaaa,$appId,$secret,$url){
	$urlss = $url."/v2/identity/auth/web/orgAuthUrl";
	$head_url = "/v2/identity/auth/web/orgAuthUrl";
    $data = json_decode($aaaa,true);
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
}
// $aaaa = '{
//     "authType":"ORG_BANK_TRANSFER",
//     "availableAuthTypes":["ORG_BANK_TRANSFER","ORG_ZM_AUTHORIZE"],
//   	"agentAuthAdvancedEnabled":["PSN_TELECOM_AUTHCODE","PSN_BANK4_AUTHCODE"],
//     "contextInfo":{
//     	"contextId":"20190822135330444",
//     	"notifyUrl":"http://baidu.com",
//     	"origin":"BROWSER",
//     	"redirectUrl":"http://baidu.com",
//     	"showResultPage":"true"
//     },
//     	"orgEntity":{
//       "certNo":"546512395648525649",
//       "organizationType":1,
//       "name":"赣州刘颂晶网络",
//       "legalRepCertNo":"360731199907050379",
//       "legalRepName":"liusongjing"
//     },
//     "repeatIdentity":"true"
// }';
// $a = authOrganBody($aaaa,$appId,$secret,$url);
// var_dump($a);die;
// {"code":0,"message":"成功","data":{"url":"https://smlfront.esign.cn:8890/identity/login?appId=7438873193¶m=5y%2B7JHvXaO2IvgucxOVa3jF1SIDkRLVQ%2FoUZRpYrw%2F1m5U5oAQz7GqibaRkfR99zj2YBAJhZ5DYf%2Ff%2FUT4s8cFen5NTvBCvR634YcZOjkI7R7lW4UpQamsAvuVI3WwbyjE6ysv%2BqQ7mXUKFrjtXQErX0K3td3mMSL23vDuPOd9w6t0Z%2FE83WHUkCas7D5Hd6agGgQZgLNg8X7XJL4H28k7RAZPXBa2qIpXlLXeIUVRG3tfZc7NmxyZgAEN9j7TZ%2BC1lNo%2BB7WxkJ2QBQu%2F9IGQ%3D%3D&lang=zh-CN","shortLink":"https://smlt.esign.cn/87EyXdzPUFj8","flowId":"1941870439547012567"}}




